package com.ruoyi.system.mapper;

import java.util.List;
import com.ruoyi.system.domain.ReportElement;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
 * 模版组件Mapper接口
 * 
 * @author ruoyi
 * @date 2021-06-16
 */
public interface ReportElementMapper 
{
    /**
     * 查询模版组件
     * 
     * @param id 模版组件ID
     * @return 模版组件
     */
    public ReportElement selectReportElementById(Long id);

    /**
     * 查询模版组件列表
     * 
     * @param brief_id 模版id
     * @return 模版组件集合
     */
    @Select("<script>" +
            "SELECT\n" +
            "\t* FROM\n" +
            "\treport_element \n" +
            "where 1=1 "+
            "<if test='name!=null'>"+
            " and a.name like concat('%', #{name}, '%') "+
            "</if>" +
            "</script>"
    )
    @Results({
            @Result(column = "show_text", property = "showText"),
            @Result(column = "element_style_icon", property = "elementStyleIcon"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "user_id", property = "userId"),
            @Result(column = "show_name", property = "showName"),
    })
    public List<ReportElement> selectReportElementList(@Param("id") Long id,
                                                       @Param("name") String name);

    /**
     * 新增模版组件
     * 
     * @param reportElement 模版组件
     * @return 结果
     */
    public int insertReportElement(ReportElement reportElement);

    /**
     * 修改模版组件
     * 
     * @param reportElement 模版组件
     * @return 结果
     */
    public int updateReportElement(ReportElement reportElement);

    /**
     * 删除模版组件
     * 
     * @param id 模版组件ID
     * @return 结果
     */
    public int deleteReportElementById(Long id);

    /**
     * 批量删除模版组件
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteReportElementByIds(Long[] ids);

    /**
     *
     * @return
     * @param elementIds
     */

    @Select("<script>Select * From report_element where id in <foreach collection = 'elementIds' item ='id' index ='index' open='(' close=')' separator=','>#{id}</foreach> " +
            "</script>")
    @Results({@Result(column = "show_text", property = "showText")})
    List<ReportElement> selectReportElementListByIds(@Param("elementIds") List<Long> elementIds);



}
